package com.lds.config.center.server.mcp.agent.controller;

import com.lds.config.center.server.mcp.agent.agent.EnvMcpAgent;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.service.AiServices;
import dev.langchain4j.service.tool.ToolProvider;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class McpController {

    private final EnvMcpAgent envMcpAgent;

    public McpController(ChatModel chat, ToolProvider toolProvider) {
        this.envMcpAgent = AiServices.builder(EnvMcpAgent.class)
                .chatModel(chat)
                .toolProvider(toolProvider)
                .build();
    }

    @GetMapping("/mcp")
    public String mcp(@RequestParam(value = "message") String message) {
        return envMcpAgent.chat(message);
    }
}
